﻿@model Resto.CostControl.Core.MaterialProcess
@{
    ViewBag.Title = "加工单维护";
    Layout = "~/Views/Shared/_LayoutForm.cshtml"; 
}
@using (Html.AjaxBeginForm("Save"))
{ 
    <!-- 主表 --> 
    <div class="pageFormContent" style="width: 600px">
        @Html.HiddenFor(model => model.Id)
        @Html.HiddenFor(model => model.OrderState)
        @Html.DWZDropDownListFor(model => model.Category, "MaterialCategory")
        @Html.DWZDateFor(model => model.ProcessDate).Required()
    </div>
    <div class="clear">
    </div>
    <!-- 子表 --> 
    <div class="pageFormDetailList">
        @Html.Css("flexigrid", "tmpl", "list")
        @Html.Js("flexigrid", "tmpl", "list")
        @(        
 Html.DWZGridFor<Resto.CostControl.Core.MaterialProcessItem>()
        .Title("品名列表")
        .ID("MaterialList")
        .Action(@Url.Action("EditList"))
        .ExtParam(new { ParentId = "$('#Id').val()", category = @ViewBag.Category ?? "", date = @ViewBag.Date ?? "" })
        .Width(580)
        .Height(285)
        .Columns(col =>
        {
            col.Bind(e => e.Id).IsKey().Sortable(false);
            col.Bind(e => e.MaterialId).Hide().Sortable(false);
            col.Bind(e => e.Code).Width(60).Sortable(false);
            col.Bind(e => e.Name).Width(60).Align(FlexiGridAlign.Left).Sortable(false);
            col.Bind(e => e.Category).EnumKey("MaterialCategory").Width(60).Sortable(false);
            col.Bind(e => e.RawMaterialId).Hide().Sortable(false);
            col.Bind(e => e.ProcessCount).Template(@Html.TextBox("ProcessCount", "${ProcessCount}", new { style = "text-align:right;width:56px" }).ToString()).Width(60).Sortable(false);
            col.Bind(e => e.ExpectedStorageCount).Template(@Html.TextBox("ExpectedStorageCount", "${ExpectedStorageCount}", new { style = "text-align:right;width:56px" }).ToString()).Width(60).Sortable(false);
            col.Bind(e => e.Id, "操作", 60).Sortable(false)
               .Template(Url.GridLink("delete", "删除", "DeleteItem('${Id}')"));
        })
        .ShowCheckBox(false)
        .UsePager(false)
        .Buttons(btn =>
        {
            btn.Bind("Add", "选择品名", FlexiGridButtonType.Add).OnPress("SelectMaterial");
        })
    )
    </div>
}
@Html.FormBar()
<script type="text/javascript">
    function SelectMaterial(e) {
        OpenModelWindow('@Url.Action("LookUp", "Dish")', { caption: "选择品名", width: 840, height: 400, onclose: function (MaterialData) {
            if (MaterialData) {
                $("#MaterialList").flexAddRows(MaterialData);
            }
        }
        });
    }

    function DeleteItem(id) {
        $("#MaterialList").flexDeleteRowData(id);
    }
</script>
